package com.xhui.vimarket.common.dao;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Criterion;

public interface BaseGenericDao<T, PK extends Serializable> {
    SessionFactory getSessionFactory();
    
    void setSessionFactory(final SessionFactory sessionFactory);
    
    Session getSession();
    
    void save(final T entity);
    
    void delete(final T entity);
    
    void delete(final PK id);
    
    T get(final PK id);
    
    List<T> getAll();
    
    List<T> getAll(String orderBy, boolean isAsc);
    
    List<T> findBy(final String propertyName, final Object value);
    
    T findUniqueBy(final String propertyName, final Object value);
    
    List<T> findByIds(List<PK> ids);
    
    <X> List<X> find(final String hql, final Object... values);
    
    <X> List<X> find(final String hql, final Map<String, ?> values);
    
    <X> X findUnique(final String hql, final Object... values);
    
    <X> X findUnique(final String hql, final Map<String, ?> values);
    
    int batchExecute(final String hql, final Object... values);
    
    int batchExecute(final String hql, final Map<String, ?> values);
    
    Query createQuery(final String queryString, final Object... values);
    
    Query createQuery(final String queryString,
        final Map<String, ?> values);
    
    List<T> find(final Criterion... criterions);
    
    T findUnique(final Criterion... criterions);
    
    Criteria createCriteria(final Criterion... criterions);
    
    void initEntity(T entity);
    
    void initEntity(List<T> entityList);
    
    Query distinct(Query query);
    
    Criteria distinct(Criteria criteria);
    
    String getIdName();
}
